//
//  HCommonCell.m
//  掌上宏力
//
//  Created by admin on 2017/6/7.
//  Copyright © 2017年 admin. All rights reserved.
//

#import "HCommonItem.h"

@interface HCommonItem ()

@property (nonatomic,weak) UIImageView *imgView;
@property (nonatomic,weak) UILabel *titleLab;

@end

@implementation HCommonItem

-(void)setDic:(NSDictionary *)dic{
    self.imgView.image = [UIImage imageNamed:dic[@"icon"]];
    self.titleLab.text = dic[@"title"];
}
-(instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        
        CGFloat fWidth = frame.size.width;
//        CGFloat fHeight = frame.size.height;
        
        CGFloat width = fWidth-50;
        CGFloat height = width;
        
        UIImageView *imgV = [[UIImageView alloc] initWithFrame:CGRectMake((fWidth-width)*0.5, 8, width, height)];
        [self addSubview:imgV];
        self.imgView = imgV;
        
        UILabel *titleL = [Factory createLabelWithFrame:CGRectMake(0, imgV.bottom+5, fWidth, 30) fontSize:15];
        titleL.textAlignment = NSTextAlignmentCenter;
        [self addSubview:titleL];
        self.titleLab = titleL;
    }
    return self;
}
+(instancetype)cellWithCollectionView:(UICollectionView *)collectionView indexPath:(NSIndexPath *)indexPath{
    static NSString *cellId = @"commonItemId";
    HCommonItem *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellId forIndexPath:indexPath];
   
    return cell;
    
}

@end
